import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout/index.vue'
import Login from '@/views/login/index.vue'
import Home from '@/views/home/Home.vue'

Vue.use(VueRouter)

// 异步加载 
//因为vue的所有路由都是加载在一个app.js里的，如果项目大，那么首页加载会是灾难。
//所以就需要把某些路由用异步加载(懒加载)的方式进行加载.
//这些都可以直接放在下面
//商品管理
const Product = () => import("@/views/product/index.vue");
const List = () => import("@/views/product/list/index.vue");
const Caregory = () => import("@/views/product/caregory/index.vue");
const AddProduct = () => import("@/views/product/list/AddProduct.vue");

const Order = () => import("@/views/order/index.vue");
const OrderList = () => import("@/views/order/list/index.vue");
const Collect = () => import("@/views/order/collect/index.vue");

const Advert = () => import("@/views/advert/index.vue");
const AdvertList = () => import("@/views/advert/list/index.vue");

//系统管理
import SystemManage from '@/views/SystemManage'
import department from '@/views/SystemManage/department'
import role from '@/views/SystemManage/role'


export default new VueRouter({
    routes: [
        {
            // 菜单栏
            path: '/',
            component: Layout,
            // 2级路由
            children: [
                {
                    path: '/',
                    name: 'home',
                    component: Home
                },
                {
                    path: '/product',//产品管理
                    name: 'product',
                    component: Product,
                    //3季
                    children: [
                        {
                            path: 'list',//访问路径得补上
                            name: 'list',
                            component: List,
                        }, 
                        {
                            path: 'caregory',//访问路径得补上
                            name: 'caregory',
                            component: Caregory,
                        },
                        {
                            path: 'add-product',//商品添加--编辑-查看 
                            name: 'ProductPage',
                            component:AddProduct,
                            meta:{//配置高亮标识
                                activeMenu:'/product/list'
                            }
                        },
                    ],
                },
                ,
                {
                    path: '/order',//订单管理
                    name: 'order',
                    component: Order,

                    children: [
                        {
                            path: 'order-list',
                            name: 'order-list',
                            component: OrderList
                        }, {
                            path: 'collect',
                            name: 'collect',
                            component: Collect
                        }
                    ]
                }
                ,
                {
                    path: '/advert',//广告管理
                    name: 'advert',
                    component: Advert,

                    children: [
                        {
                            path: 'advert-list',
                            name: 'advert-list',
                            component: AdvertList
                        }
                    ]
                }
                ,
                {
                    path: '/system',//系统管理
                    name: 'system',
                    component: SystemManage,
                    redirect: '/system/role',
                    meta: {
                        title: "系统管理"
                    },
                    children: [
                        {
                            path: 'role',
                            name: 'role',
                            component: role,
                            meta: {
                                title: "角色管理"
                            },
                        },
                        {
                            path: 'department',
                            name: 'department',
                            component: department,
                            meta: {
                                title: "部门管理"
                            },
                        }
                    ]
                },
            ]
        },
        {
            path: '/login',
            name: 'login',
            component: Login,
        }
    ]
})
// const routes = [
//     {
//         path:'/',
//         component:Layout,
//       },
//       {
//         path:'/login',
//         name:'login',
//         component:Login,
//       }
// ]
// const router = new VueRouter({
//     mode: 'history',
//     base: process.env.BASE_URL,
//     routes
// })
